package cn.iocoder.yudao.module.product.selection.controller.admin;

import cn.iocoder.yudao.framework.business.basic.controller.CrudController;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.product.selection.pojo.vo.ProductSupplySelectionQueryDTO;
import cn.iocoder.yudao.module.product.selection.pojo.vo.ProductSupplySelectionSaveDTO;
import cn.iocoder.yudao.module.product.selection.pojo.vo.ProductSupplySelectionVO;
import cn.iocoder.yudao.module.product.selection.service.ProductSupplySelectionService;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Tag(name = "管理后台 - 供应链选品库")
@RestController
@RequestMapping("/product/supply/selection")
@Validated
public class ProductSupplySelectionController implements CrudController<ProductSupplySelectionVO, ProductSupplySelectionSaveDTO, ProductSupplySelectionQueryDTO> {

    @Resource
    private ProductSupplySelectionService productSupplySelectionService;

    @PreAuthorize("@ss.hasAnyRoles('super_admin', 'platform_admin', 'tenant_admin')")
    @Override
    public CommonResult<Long> create(ProductSupplySelectionSaveDTO param) {
        return CommonResult.success(productSupplySelectionService.create(param));
    }

    @PreAuthorize("@ss.hasAnyRoles('super_admin', 'platform_admin', 'tenant_admin')")
    @Override
    public CommonResult<Boolean> update(ProductSupplySelectionSaveDTO param) {
        return CommonResult.success(productSupplySelectionService.update(param));
    }

    @PreAuthorize("@ss.hasAnyRoles('super_admin', 'platform_admin', 'tenant_admin')")
    @Override
    public CommonResult<Boolean> delete(Long id) {
        return CommonResult.success(productSupplySelectionService.delete(id));
    }

    @Override
    public CommonResult<ProductSupplySelectionVO> getDetail(Long id) {
        return CommonResult.success(productSupplySelectionService.getDetail(id));
    }

    @Override
    public CommonResult<PageResult<ProductSupplySelectionVO>> getPage(Integer pageNo, Integer pageSize, ProductSupplySelectionQueryDTO param) {
        return CommonResult.success(productSupplySelectionService.getPage(pageNo, pageSize, param));
    }

}
